package models

import (
	"time"

	"github.com/google/uuid"
)

type CardModel struct {
	BaseModel
	UUID           uuid.UUID          `json:"uuid" gorm:"comment:卡UUID"`
	CardTemplateId uint               `json:"card_template_id" gorm:"comment:卡模Id"`
	CreateByUserId uint               `json:"create_by_user_id" gorm:"comment:创建人"`
	Customer       string             `json:"customer" gorm:"comment:客户名"`
	CustomerId     uint               `json:"customer_id" gorm:"comment:客户user id"`
	Count          int                `json:"count" gorm:"comment:计卡总数"`
	MarkCount      int                `json:"mark_count" gorm:"comment:已计卡总数"`
	Mobile         string             `json:"mobile" gorm:"comment:手机"`
	StartAt        time.Time          `json:"start_at" gorm:"comment:开始日期"`
	ExpiresAt      time.Time          `json:"expires_at" gorm:"comment:过期日期"`
	Status         int8               `json:"status" gorm:"default:0;comment:状态:1生效,2用完,3作废"`
	CardTemplate   *CardTemplateModel `json:"card_template" gorm:"foreignKey:CardTemplateId;association_autoupdate:false;association_autocreate:false"`
	CardMarks      []CardMarkModel    `json:"card_marks" gorm:"foreignKey:CardId"`
}

func (CardModel) TableName() string {
	return "card"
}
